import random
import numpy as np

def generate_random_array(size, min_val=0, max_val=1000):
    """生成随机数组"""
    return [random.randint(min_val, max_val) for _ in range(size)]

def generate_sorted_array(size, min_val=0, max_val=1000):
    """生成已排序数组"""
    arr = generate_random_array(size, min_val, max_val)
    return sorted(arr)

def generate_reverse_sorted_array(size, min_val=0, max_val=1000):
    """生成逆序数组"""
    arr = generate_random_array(size, min_val, max_val)
    return sorted(arr, reverse=True)

def generate_nearly_sorted_array(size, min_val=0, max_val=1000, swap_times=10):
    """生成近似排序数组"""
    arr = generate_sorted_array(size, min_val, max_val)
    for _ in range(swap_times):
        i, j = random.randint(0, size-1), random.randint(0, size-1)
        arr[i], arr[j] = arr[j], arr[i]
    return arr

def generate_test_cases():
    """生成所有测试用例"""
    test_cases = {
        'small_random': generate_random_array(100),
        'medium_random': generate_random_array(1000),
        'large_random': generate_random_array(10000),
        'sorted': generate_sorted_array(1000),
        'reverse_sorted': generate_reverse_sorted_array(1000),
        'nearly_sorted': generate_nearly_sorted_array(1000),
        'duplicate': [random.randint(0, 10) for _ in range(1000)],  # 包含大量重复元素
        'single_value': [42] * 1000,  # 所有元素相同
    }
    return test_cases

if __name__ == "__main__":
    # 测试数据生成器
    test_cases = generate_test_cases()
    for name, arr in test_cases.items():
        print(f"\n{name} array (first 5 elements): {arr[:5]}")
        print(f"Array length: {len(arr)}") 